﻿using System;
using System.Text;

namespace SillyCube.Utils
{
    public static class ArrayFormat
    {
        public static string ArrayToString<T>(T[] array, Func<T, string> mapper)
        {
            StringBuilder sb = new StringBuilder("{");
            bool first = true;
            foreach (var elem in array)
            {
                sb.Append(mapper(elem));
                if (!first)
                    sb.Append(", ");
                
                first = false;
            }
            
            sb.Append("}");

            return sb.ToString();
        }
    }
}